﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using CrystalDecisions.Shared;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Web;
using System.Data.SqlClient;

public partial class SaleReport : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //string sql = "Select ISBN,BookName,LastMonthSale,Forecast1,Forecast2,Farecast3 From OrderPrediction4Store where StoreID='01'";
        string sql = "select isbn, xx, yy ,sale from salereporthq";
        string DBConfig_sql = @"Data Source=ONEWAY\SQLSERVER;Initial Catalog=BookShop;User ID=sa";
        DataSet ds = new DataSet();
        SqlConnection sqlCon = new SqlConnection(DBConfig_sql);
        SqlCommand sqlCmd = new SqlCommand(sql, sqlCon);
        SqlDataAdapter sqlAd = new SqlDataAdapter();
        sqlAd.SelectCommand = sqlCmd;
        //sqlAd.Fill(ds, "OrderPrediction4Store");
        sqlAd.Fill(ds, "SaleReportHQ");
        CrystalReportSource1.ReportDocument.Load(Server.MapPath("Reports/SaleReportHQ.rpt"));
        //注意此处必需指明Dataset中的表的名称，否则会提示“您请求的报表需要更多信息.”
        CrystalReportSource1.ReportDocument.SetDataSource(ds.Tables["SaleReportHQ"]);
        //{?}中的参数可以不用赋值，即使赋了值也不起作用。
        // CrystalReportSource1.ReportDocument.ParameterFields["Parm"].CurrentValues.AddValue("1234567");
        CrystalReportSource1.ReportDocument.SetDataSource(ds);
        CrystalReportViewer1.ReportSource = CrystalReportSource1;
        CrystalReportSource1.DataBind();

        CrystalReportViewer1.ReportSource = CrystalReportSource1;
        CrystalReportViewer1.DataBind();
    }
}
